<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>接收通信设备</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="../../css/style.css">
	<script type="text/javascript" src="../../js/jquery-1.8.2.js"></script>
	<script type="text/javascript" src="../../js/dialog/jquery.artDialog.source.js?skin=default"></script>
	<script type="text/javascript" src="../../js/dialog/plugins/iframeTools.source.js"></script>
	<script type="text/javascript" src="../../js/jquery.ztree.all-3.5.min.js"></script>
	<script type="text/javascript" src="../../js/datepicker/WdatePicker.js"></script>
	<script type="text/javascript" src="../../js/jquery.form.js"></script>
	<script type="text/javascript" src="../../js/jquery.page.js"></script>
	<script type="text/javascript" src="../../js/base.js"></script>
</head>
<body class="app">
	<h3>接收通信设备</h3>
	<form class="search" name="search">
		<div class="tbdiv">
		<table>
			<tr>
				<th>通信设备号：</th>
				<td><input name="devId" type="text" class="inputText" /></td>
				<th>标记：</th>
				<td><input name="remark" type="text" class="inputText" /></td>
				<th>审核状态：</th>
				<td>
					<select name="checkStatus">
						<option value="">-请选择-</option>
						<option value="0">已发放</option>
						<option value="1">已接收</option>
						<option value="2">已退回</option>
						<option value="3">已关联</option>
					</select>
				</td>
				<td align="right"><input type="submit" class="inputButton" value="查询"/></td>
			</tr>
		</table>
		</div>
	</form>
	<div id="list"></div>
	<div id="view" style="width:650px;display:none;">
		<form id="saveForm" name="saveForm" action="txsbgl_save.action" method="post">
		<input type="hidden" name="id" />
		<dl class="view">
			<dt class="giant">设备号：</dt>
			<dd class="giant" id="lh_devId"><input type="text" class="inputText" style="width:150px" name="devId" ver="empty" msg="请输入设备编号。" /></dd>
			<dt class="giant">协议类型：</dt>
			<dd class="giant"><select name="pact" style="width:159px" ver="empty" msg="请选择协议类型。"></select></dd>
			<dt class="giant">所属区域：</dt>
			<dd class="giant">
				<input type="hidden" name="areaName" value="" ver="empty" msg="请选择所属区域。"/>
				<input type="text" class="inputText" name="areaNameN" value="" style="width:347px;*width:348px;cursor:pointer;" readonly="readonly" />
			</dd>
			<dt class="giant">所属行政单位：</dt>
			<dd class="giant"><select name="adminCode" ver="empty" msg="请选择所属行政单位。" style="width:159px"></select></dd>
			<dt class="giant">所属机构：</dt>
			<dd class="giant"><select name="agencyType" ver="empty" msg="请选择所属机构。" style="width:159px"></select></dd>
			<dt class="giant">所属单位：</dt>
			<dd class="giant"><select name="unitCode" ver="empty" msg="请选择所属单位。"><option value="">-请选择-</option></select></dd>
			<dt class="giant" style="height:44px;">标记：</dt>
			<dd class="giant" style="height:44px;">
				<p>该标记内容可以作为主要的通信设备筛选条件!</p>
				<p><input type="text" class="inputText" style="width:347px" name="remark" ver="empty" msg="请输入设备编号。" /></p>
			</dd>
			<div class="cl"></div>
		</dl>
		</form>
	</div>
	<div class="areaTree"><div id="areaTree" class="ztree"></div></div>
	<script type="text/javascript">
	$(function(){
		$(document.search).ajaxForm({
			beforeSubmit:function(formData){
				var param = $(formData).formParam();
				$('#list').page('param',param);
				$('#list').page('show');
				return false;
			}
		});
		//分页列表
		$('#list').page({
			url:'txsbqr_search.action',
			config:'pageinfo,record,first,last,next,prev,jump',
			items:[{
				title:'设备号',
				name:'devId'
			},{
				title:'所属行政监管单位',
				name:'adminName'
			},{
				title:'所属单位',
				name:'agencyType',
				irender:function(row){
					if(row.propertyName!=null){
						return row.propertyName;
					}
					if(row.serviceName!=null){
						return row.serviceName;
					}
				}
			},{
				title:'标记',
				name:'remark'
			},{
				title:'审核状态',
				name:'checkStatus',
				irender:function(row){
					var text = '';
					switch(row.checkStatus){
						case '0':
							text = '已发放';
							break;
						case '1':
							text = '已接收';
							break;
						case '2':
							text = '已退回';
							break;
					}
					return text;
				}
			},{
				title:'详情',
				name:'checkStatus',
				width:95,
				irender:function(row){
					$yes = $('<a href="javascript:void(0)">【接收】</a>');
					$no = $('<a href="javascript:void(0)">【退回】</a>')
					$yes.click(function(){
						upd({checkStatus:1,devId:row.devId});
					});
					$no.click(function(){
						upd({checkStatus:2,devId:row.devId});
					});
					if(row.checkStatus == '0'){
						return $yes.after($no);
					}else{
						return '';
					}
				}
			}]
		});
	});
	var upd = function(para){
		var text = '';
		if(para.checkStatus == 1){
			text = '您确认接收此设备吗？';
		}else if (para.checkStatus == 2){
			text = '您确认退回此设备吗？';
		}
		$.dialog.confirm(text,function(){
			$.post('txsbqr_save.action',para,function(data){
				if(data > 0){
					/*
					if(para.checkStatus == 1){
						$.dialog.alert('已接收');
					}else if (para.checkStatus == 2){
						$.dialog.alert('已退回');
					}*/
					$('#list').page('show');
				}else{
					$.dialog.alert('操作失败');
				}
			},'json');
		});
	} 
	</script>
</body>
</html>
